<template>
    <div class="body">
       <img src="../assets/live-logo.gif" alt="">
    </div>
</template>
<script>
import {wechatLogin} from '../ajax';
export default {
    name: 'WxAuth',
    async created(){
      let query = window.location.search.split('=');
        console.log(query);
        return;
        // console.log(this.$route.query.state)
      // 如果连接中有微信返回的 code，则用此 code 调用后端接口，向微信服务器请求用户信息
      // 如果不是从微信重定向过来的，没有带着微信的 code，则直接进入首页
      if (this.$route.query.code) {
          let params = (this.$route.query.state).split('-');
          this.$store.commit('admin_id',params[0])
          const data = {
              code:this.$route.query.code,
              admin_id:params[0],
              state:params[1]?params[1]:''
          }
            let redirectUrl = sessionStorage.getItem('wxRedirectUrl');
          wechatLogin(data).then(res=>{
              this.$store.commit('wxUserInfo',res);
            this.$router.replace(redirectUrl)
          })
      } else {
        this.$router.replace('/')
      }
    },
  }
</script>
<style scoped lang="scss">
    .body{
        height: 100vh;
        display: flex;
        justify-content: center;
        align-items: center;
        img{
            width: 4rem;
            height: 4rem;
        }
    }
    
</style>